package com.vca.front.controller;

import com.alibaba.fastjson.JSONArray;
import com.vca.common.result.CommonResult;
import com.vca.service.service.UserCollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:用户收藏控制器
 * @author:chenbing
 * @date 2022/12/1 17:15
 */
@Slf4j
@RestController("UserCollectionController")
@RequestMapping("api/front/collection")
@Api(tags = "用户收藏控制器")
public class UserCollectionController {
    @Autowired
    private UserCollectionService userCollectionService;

    /**
     * @Description:用户收藏课程/讲座/展览/商品通用API
     * @author:chenbing
     * @date 2022/12/1 17:18
     */
    @ApiOperation(value = "用户收藏课程/讲座/展览/商品通用API")
    @PostMapping(value = "/collect")
    public CommonResult<String> collect(
            @RequestHeader(value = "language",required = false) String language,
            @RequestParam(value = "type") Integer type,
            @RequestParam(value = "mainId") Integer mainId
    ) {
        JSONArray result_collect = userCollectionService.collect(language,type, mainId);
        //System.out.println(result_collect.get(0)+"==========="+result_collect.get(1));
        return CommonResult.success(result_collect.get(0).toString(),result_collect.get(1).toString());
    }
}
